<html>
<head><meta charset="utf-8"><title>Custom allocators for auto-boxing · wg-async-foundations · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/index.html">wg-async-foundations</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html">Custom allocators for auto-boxing</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="245495909"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245495909" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245495909">(Jul 09 2021 at 20:49)</a>:</h4>
<p>There had been a variety of discussions around where it might be helpful to have Boxes. One is recursion. The other one async traits. And yet another one is spawning inside scopes. </p>
<p>All of that obviously is problematic on embedded. <br>
I’m wondering if we can get it in an acceptable state by allowing users (or more likely: runtimes) to specify custom allocators using the proposed allocation Apis for that use-case. </p>
<p>An allocator reference could be threaded through <code>Context</code>, and thereby enable task-local (or scope-local) allocation behavior. </p>
<p>Probably needs then fallible spawn methods, and also a way to specify that recursion failed due to OOM, but it might be doable. </p>
<p>The whole thing is however just a brainstorm so far and orthogonal to all the other ideas.</p>



<a name="245499765"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245499765" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thales Fragoso <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245499765">(Jul 09 2021 at 21:11)</a>:</h4>
<p>There are indeed better allocators for embedded (i.e. TLSF), but even then, it doesn't apply to most cases. A lot of people would be pushed away from async if that would mean alloc in embedded</p>



<a name="245500516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245500516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245500516">(Jul 09 2021 at 21:15)</a>:</h4>
<p>I think there's a false equivalence here</p>



<a name="245500682"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245500682" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245500682">(Jul 09 2021 at 21:15)</a>:</h4>
<p>Saying that <em>sometimes async will use allocation</em> is not saying <em>async must use allocation</em></p>



<a name="245500857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245500857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245500857">(Jul 09 2021 at 21:16)</a>:</h4>
<p>as an example, today, you just <em>can't</em> do recursive functions without a box or <em>some</em> sort of intervention</p>



<a name="245500886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245500886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245500886">(Jul 09 2021 at 21:16)</a>:</h4>
<p>so no embedded code is using that</p>



<a name="245500932"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245500932" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245500932">(Jul 09 2021 at 21:16)</a>:</h4>
<p>if we made it "just work", all embedded code would keep working</p>



<a name="245500985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245500985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245500985">(Jul 09 2021 at 21:16)</a>:</h4>
<p>if code wants to be no-std compatible, that's a commitment</p>



<a name="245501012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245501012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245501012">(Jul 09 2021 at 21:16)</a>:</h4>
<p>and it abides by a subset of the language</p>



<a name="245501041"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245501041" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245501041">(Jul 09 2021 at 21:17)</a>:</h4>
<p>I do think we want to make that overlap as big as we can</p>



<a name="245501373"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245501373" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245501373">(Jul 09 2021 at 21:18)</a>:</h4>
<p>The issue with allocators on embedded is not "you <em>can't</em> use alloc"</p>



<a name="245501471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245501471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245501471">(Jul 09 2021 at 21:19)</a>:</h4>
<p>you can get alloc working just fine, see this for example <a href="https://github.com/rust-embedded/alloc-cortex-m">https://github.com/rust-embedded/alloc-cortex-m</a><br>
with that Box, Vec, Rc, Arc etc Just Work exactly like on std</p>



<a name="245501868"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245501868" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245501868">(Jul 09 2021 at 21:21)</a>:</h4>
<p>Sure</p>



<a name="245501877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245501877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245501877">(Jul 09 2021 at 21:21)</a>:</h4>
<p>the issue is "using allocators is a bad practice"</p>



<a name="245502174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245502174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245502174">(Jul 09 2021 at 21:22)</a>:</h4>
<p>predicting memory usage at compile time is super hard if you're using allocators, no matter whether it's the default alloc or a custom pool/arena one.</p>



<a name="245502308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245502308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245502308">(Jul 09 2021 at 21:23)</a>:</h4>
<p>I think it should absolutely be a goal that async fn is usable wthout an allocator</p>



<a name="245502332"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245502332" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245502332">(Jul 09 2021 at 21:23)</a>:</h4>
<p>(not sure if that was unclear?)</p>



<a name="245502402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245502402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245502402">(Jul 09 2021 at 21:23)</a>:</h4>
<p>I do not, however, think it should be a goal that <em>all async users</em> should forego allocation</p>



<a name="245502499"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245502499" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245502499">(Jul 09 2021 at 21:24)</a>:</h4>
<p>(I'm sure nobody is arguing that)</p>



<a name="245502537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245502537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thales Fragoso <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245502537">(Jul 09 2021 at 21:24)</a>:</h4>
<p>Sorry, I understand that it doesn't mean that async itself would need alloc, but I was just afraid of new things that get added to it only working with alloc, tbh I still need to look better a scopes to really having a saying here, and I understand that some stuff will need alloc and if there isn't a way around it, then it's completely fine</p>



<a name="245502553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245502553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245502553">(Jul 09 2021 at 21:24)</a>:</h4>
<p>But in particular I think that it's perfectly fine if the majority of async users turn to APIs that require allocation by default. In fact, they already do.</p>



<a name="245502648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245502648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245502648">(Jul 09 2021 at 21:24)</a>:</h4>
<p>I think there is a thing to consider here, which is:</p>



<a name="245502699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245502699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245502699">(Jul 09 2021 at 21:25)</a>:</h4>
<p>well, that's not actually true :0</p>



<a name="245502720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245502720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245502720">(Jul 09 2021 at 21:25)</a>:</h4>
<p>of course not, but for example from the hackmd I get that things as basic as <code>join</code> and <code>select</code> will require the new "scopes" API which will require allocation, which somewhat worries me</p>



<a name="245502760"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245502760" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245502760">(Jul 09 2021 at 21:25)</a>:</h4>
<p>I was going to say that with <code>FuturesUnordered</code>, people might be writing code that is more no-std friendly by default, but actually <code>FuturesUnordered</code> requires allocation in just the same way as the scopes we're talking about</p>



<a name="245502883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245502883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245502883">(Jul 09 2021 at 21:26)</a>:</h4>
<p>Still, I can imagine that if people turn more to (e.g.) <code>join</code>, versus write <code>scope.spawn</code> twice by default, then they will tend to produce libraries and things that are more no-std friendly than not</p>



<a name="245502890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245502890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245502890">(Jul 09 2021 at 21:26)</a>:</h4>
<p>and that has value</p>



<a name="245502917"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245502917" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245502917">(Jul 09 2021 at 21:26)</a>:</h4>
<p><span class="user-mention silent" data-user-id="348152">Dario Nieuwenhuis</span> <a href="#narrow/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing/near/245502720">said</a>:</p>
<blockquote>
<p>of course not, but for example from the hackmd I get that things as basic as <code>join</code> and <code>select</code> will require the new "scopes" API which will require allocation, which somewhat worries me</p>
</blockquote>
<p>I think I was actually wrong about that</p>



<a name="245502950"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245502950" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245502950">(Jul 09 2021 at 21:26)</a>:</h4>
<p>in particular, I don't believe <code>join</code> requires it</p>



<a name="245502999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245502999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245502999">(Jul 09 2021 at 21:26)</a>:</h4>
<p>in <a href="https://github.com/rust-lang/wg-async-foundations/issues/222">wg-async-foundations#222</a>, I wrote a more narrowly tailored condition</p>



<a name="245503041"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245503041" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245503041">(Jul 09 2021 at 21:27)</a>:</h4>
<p>I think the cases where we should use scopes are: <em>APIs that start parallel work and yield intermediate results without waiting for all of it to finish</em></p>



<a name="245503052"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245503052" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245503052">(Jul 09 2021 at 21:27)</a>:</h4>
<p><code>FuturesUnordered</code> indeed doesn't work without alloc, but it's really hard to use so I haven't missed it much :) Either way, you rarely do "awaiting an arbitrary number of things" on embedded, you can mostly get away with join/select</p>



<a name="245503095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245503095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245503095">(Jul 09 2021 at 21:27)</a>:</h4>
<p>so, join and select are ok</p>



<a name="245503110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245503110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245503110">(Jul 09 2021 at 21:27)</a>:</h4>
<p>select in particular cancels the other work</p>



<a name="245503139"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245503139" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245503139">(Jul 09 2021 at 21:27)</a>:</h4>
<p>which for my purposes is equivalent to "waiting for it to finish"</p>



<a name="245503188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245503188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245503188">(Jul 09 2021 at 21:27)</a>:</h4>
<p>I don't believe that they can produce the kind of "nested await" problem I am trying to avoid</p>



<a name="245503220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245503220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245503220">(Jul 09 2021 at 21:28)</a>:</h4>
<p>(the very thing that makes <code>FuturesUnordered</code> hard to use, if I understand you)</p>



<a name="245503303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245503303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245503303">(Jul 09 2021 at 21:28)</a>:</h4>
<blockquote>
<p>the buffered combinator would take a scope parameter to use for spawning:<br>
The join combinator would likely be replaced with a method on scope</p>
</blockquote>



<a name="245503342"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245503342" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245503342">(Jul 09 2021 at 21:28)</a>:</h4>
<p>is that from <a href="https://github.com/rust-lang/wg-async-foundations/issues/222">wg-async-foundations#222</a> ?</p>



<a name="245503349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245503349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245503349">(Jul 09 2021 at 21:28)</a>:</h4>
<p>or the hackmd</p>



<a name="245503370"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245503370" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245503370">(Jul 09 2021 at 21:28)</a>:</h4>
<p>yep <a href="https://nikomatsakis.github.io/wg-async-foundations/vision/harmonic/compose_control_scheduling/scoped.html">https://nikomatsakis.github.io/wg-async-foundations/vision/harmonic/compose_control_scheduling/scoped.html</a></p>



<a name="245503382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245503382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245503382">(Jul 09 2021 at 21:28)</a>:</h4>
<p>ok, that's a mistake :)</p>



<a name="245503405"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245503405" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245503405">(Jul 09 2021 at 21:28)</a>:</h4>
<p>let me fix</p>



<a name="245503462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245503462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245503462">(Jul 09 2021 at 21:29)</a>:</h4>
<p>ah okay :)</p>



<a name="245503477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245503477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245503477">(Jul 09 2021 at 21:29)</a>:</h4>
<p>I agree with your point that there should be some common primitives for concurrency that do not require allocation</p>



<a name="245503540"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245503540" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245503540">(Jul 09 2021 at 21:29)</a>:</h4>
<p>fortunately I don't think that leads to the problems I am hoping to avoid</p>



<a name="245503554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245503554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245503554">(Jul 09 2021 at 21:29)</a>:</h4>
<p>if the plan is to stabilize basic no-alloc combinators like join/select AND the fancier scopes api, I'm all in for it! :)</p>



<a name="245503600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245503600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245503600">(Jul 09 2021 at 21:29)</a>:</h4>
<p>to be clear I'm not saying "all new APIs should be no-alloc" at all</p>



<a name="245503733"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245503733" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245503733">(Jul 09 2021 at 21:30)</a>:</h4>
<p>and the new scopes api looks muuuuuch nicer than FuturesUnordered btw</p>



<a name="245503743"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245503743" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245503743">(Jul 09 2021 at 21:30)</a>:</h4>
<p><span class="user-mention silent" data-user-id="348152">Dario Nieuwenhuis</span> <a href="#narrow/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing/near/245503370">said</a>:</p>
<blockquote>
<p>yep <a href="https://nikomatsakis.github.io/wg-async-foundations/vision/harmonic/compose_control_scheduling/scoped.html">https://nikomatsakis.github.io/wg-async-foundations/vision/harmonic/compose_control_scheduling/scoped.html</a></p>
</blockquote>
<p>ah yeah I forgot to edit that text</p>



<a name="245503821"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245503821" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245503821">(Jul 09 2021 at 21:30)</a>:</h4>
<p>actually it looks like I left off mid-edit</p>



<a name="245503844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245503844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245503844">(Jul 09 2021 at 21:31)</a>:</h4>
<p>good catch :)</p>



<a name="245503875"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245503875" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245503875">(Jul 09 2021 at 21:31)</a>:</h4>
<p>I also wrote: " (Combinators like <code>join</code> are distinct, because they don't give access to intermediate results; similarly <code>race</code> is distinct because of <a href="http://./cancellation.md">cancellation</a>)."</p>



<a name="245503899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/245503899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#245503899">(Jul 09 2021 at 21:31)</a>:</h4>
<p>which was my realization while reading your comments on the hackmd...</p>



<a name="246336552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/246336552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#246336552">(Jul 17 2021 at 18:12)</a>:</h4>
<p>Back to this thread: My main idea was not to say "embedded should use allocating" APIs - that's certainly wrong, and you should avoid them as much as possible. And providing APIs which don't allocate can be useful for <code>std</code> as well as <code>no-std</code> environments due to performance - therefore theey should definitely be kept around as long as they make sense and are actually implementable.</p>
<p>The goal was to provide tools to make additional potentially-allocating APIs still available on embedded/no-std systems, and give users the flexibility to decide on whether to use them or not. That decision can still be taken by each user or team on their own.</p>
<p>Using an allocating scope API is not necessarily wrong on embedded if you can guarantee static memory consumption. That can e.g. be achieved by only spawning tasks dynamically at startup, and make everything long-lived tasks. In that case sizing the memory available for the task allocator is not different from distributing stack memory for traditional threads on RTOS. You will also need to profile and adjust that from time to time - and tooling might help.</p>



<a name="246350536"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/246350536" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#246350536">(Jul 17 2021 at 23:57)</a>:</h4>
<p>Agreed! IMO the ideal shiny future is:</p>
<ul>
<li>All "basic" stuff (such as Futures, join/select combinators, async fn in traits) should be no-alloc. You should be able to have a "reasonably ergonomic" experience without alloc.</li>
<li>Higher-level stuff such as the Scope API, autoboxed traits / recursive async fns etc can use alloc to offer the "most ergonomic" experience, ideally with support for custom allocators too.</li>
</ul>



<a name="246350785"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Custom%20allocators%20for%20auto-boxing/near/246350785" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dario Nieuwenhuis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Custom.20allocators.20for.20auto-boxing.html#246350785">(Jul 18 2021 at 00:03)</a>:</h4>
<p>Tuning RTOS stack sizes sucks hard, BTW. Rust async shouldn't settle for that.</p>
<p>It's already possible to do no-alloc everything-statically-allocated async on embedded Rust today, without tuning any stack/pool size. See <a href="http://github.com/embassy-rs/embassy/">embassy</a>. We should keep it that way :)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>